import dayjs from 'dayjs'
import React from 'react'
import type { DictItem } from '@/types'

interface columnType {
  title: string;
  dataIndex?: string;
  key: string;
  render?: any,
  width?: number
}

export const filterOptions = (
  statusDict: DictItem[],
  pathname: string
) => {
  const list = [
    {
      type: 'input',
      key: 'bizTeamName',
      label: '业务团队'
    }, {
      type: 'input',
      key: 'customerName',
      label: '客户姓名'
    }, {
      type: 'input',
      key: 'comboName',
      label: '套餐'
    }, {
      type: 'input',
      key: 'createUserName',
      label: '坐席名称'
    }, {
      type: 'input',
      key: 'customerPhone',
      label: '客户手机'
    }, {
      type: 'select',
      key: 'status',
      label: '订单状态',
      options: statusDict
    }, {
      type: 'RangePicker',
      key: 'createTime',
      label: '创建时间'
    }, {
      type: 'RangePicker',
      key: 'updateTime',
      label: '更新时间'
    }, {
      type: 'RangePicker',
      key: 'appointmentProcessingDate',
      label: '办理日期'
    }]
  if ( pathname === '/order/seat-order') {
    return list.filter((item) => {
      return !['bizTeamName'].includes(item.key)
    })
  }
  // if ( pathname === '/order/invite-list') {
  //   return list.filter((item) => {
  //     return !['status'].includes(item.key)
  //   })
  // }
  if ( pathname === '/order/intentional-order') {
    list.push({
      type: 'RangePicker',
      key: 'intendedDate',
      label: '意向日期'
    })
  }
  return list
}

export const orderListcolumns = (pathname: string): columnType[] => {

  const intendedOrder = pathname === '/order/intentional-order' ? [
    {
      title: '意向日期',
      dataIndex: 'intendedDate',
      key: 'id'
    }
  ] : []
  return [
    {
      title: '客户',
      dataIndex: 'customerName',
      render: (_: any, record: any) => (
        <div>
          <p>姓名：{record.customerName}</p>
          <p>手机：{record.customerPhone}</p>
        </div>
      ),
      key: 'id'
    },
    {
      title: '状态',
      dataIndex: 'statusName',
      key: 'id'
    },
    {
      title: '办理详情',
      dataIndex: 'processingDetail',
      width: 300,
      key: 'id'
    },
    {
      title: '备注',
      dataIndex: 'orderComment',
      key: 'id'
    },
    {
      title: '区域',
      dataIndex: 'belongingArea',
      render: (_: any, record: any) => (
        <div>
          <p>{record.belongingArea}</p>
          <p>{record.customerAddress}</p>
        </div>
      ),
      key: 'id'
    },
    // {
    //   title: '详细地址',
    //   dataIndex: 'customerAddress',
    //   key: 'id'
    // },
    {
      title: '坐席团队',
      dataIndex: 'seatTeamName',
      key: 'id'
    },
    {
      title: '坐席名称',
      dataIndex: 'seatUsername',
      key: 'id'
    },
    {
      title: '业务类型',
      dataIndex: 'bizTypeName',
      key: 'id'
    },
    {
      title: '套餐',
      dataIndex: 'comboName',
      key: 'id'
    },
    {
      title: '礼品',
      dataIndex: 'giftName',
      key: 'id'
    },
    {
      title: '办理日期',
      dataIndex: 'appointmentProcessingDate',
      key: 'id'
    },
    ...intendedOrder,
    {
      title: '创建时间',
      dataIndex: 'createTime',
      key: 'createTime',
      render: (_: any, record: any) => (
        <p>{dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss')}</p>
      )
    },
    {
      title: '业务员团队',
      dataIndex: 'bizTeamName',
      key: 'id'
    },
    {
      title: '业务员姓名',
      dataIndex: 'bizTeamUsername',
      key: 'id'
    },
    // TODO
    {
      title: '办理主号',
      dataIndex: 'processingMainNumber',
      key: 'id'
    },
    {
      title: '冻结金额',
      dataIndex: 'freezeAmount',
      key: 'id'
    },
    {
      title: '销售机型',
      dataIndex: 'salesModels',
      key: 'id'
    },
    {
      title: '手机来源',
      dataIndex: 'phoneSource',
      key: 'id'
    },
    {
      title: '订单号',
      dataIndex: 'orderNo',
      key: 'id'
    }
    // TODO END
  ]
}